home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 2000 August: Tool Chest / Dev.CD Aug 00 TC Disk 2.toast / pc / sample code / human interface toolbox / progressbars / barebones.h < prev    next >
Encoding:
C/C++ Source or Header  |  2000-06-23  |  3.2 KB  |  229 lines

  1. /*
  2.     File:        BareBones.h
  3.  
  4.     Contains:    Common header file included by all source files
  5.  
  6.     Written by: Chris White    
  7.  
  8.     Copyright:    Copyright © 1996-1999 by Apple Computer, Inc., All Rights Reserved.
  9.  
  10.                 You may incorporate this Apple sample source code into your program(s) without
  11.                 restriction. This Apple sample source code has been provided "AS IS" and the
  12.                 responsibility for its operation is yours. You are not permitted to redistribute
  13.                 this Apple sample source code as "Apple sample source code" after having made
  14.                 changes. If you're going to re-distribute the source, we require that you make
  15.                 it clear in the source that the code was descended from Apple sample source
  16.                 code, but that you've made changes.
  17.  
  18.     Change History (most recent first):
  19.                 8/10/1999    Karl Groethe    Updated for Metrowerks Codewarror Pro 2.1
  20.                 
  21.  
  22. */
  23.  
  24. #ifndef __BAREBONES__
  25. #define __BAREBONES__
  26.  
  27.  
  28.  
  29. #ifndef __DIALOGS__
  30.     #include <Dialogs.h>
  31. #endif
  32.  
  33. #ifndef __THREADS__
  34.     #include <Threads.h>
  35. #endif
  36.  
  37.  
  38.  
  39.  
  40. #define DEBUGGING    1        // Anything that shouldn't normally occur
  41. #define WARNINGS    0        // Something that can occur, but you might like to know about
  42.  
  43.  
  44.  
  45.  
  46. enum
  47. {
  48.     // Generall application stuff
  49.     
  50.     kCreatorCode = 'prgr',                    // Progress Bars
  51.     kSleepTime = 60L
  52.  
  53. };
  54.  
  55.  
  56.  
  57. enum
  58. {
  59.     // Menu ID numbers
  60.     
  61.     kMenuBarID = 1000,
  62.     kAppleMenu = 1000,
  63.     kFileMenu = 1001,
  64.     kProgressBarsMenu
  65. };
  66.  
  67.  
  68.  
  69. enum
  70. {
  71.     // Apple menu commands
  72.     
  73.     cAbout = 1
  74. };
  75.  
  76.  
  77.  
  78. enum
  79. {
  80.     // File menu commands
  81.     
  82.     cQuit = 1
  83. };
  84.  
  85.  
  86.  
  87. enum
  88. {
  89.     // ProgressBars menu commands
  90.     
  91.     cToggleThreads = 1,
  92.     cSeperator1,
  93.     cStandard,
  94.     cBarberPole
  95. };
  96.  
  97.  
  98.  
  99.  
  100.  
  101.  
  102. enum
  103. {
  104.     // General Windows and Dialogs
  105.  
  106.     kDisplayWindow = 1000,
  107.     kAboutDialog,
  108.      kErrorDialog
  109. };
  110.  
  111.  
  112.  
  113. enum
  114. {
  115.     // Progress Dialog
  116.     
  117.     kProgressDialogID    = 1000,
  118.         kCancelItemID    = 1,
  119.         kUserItemID,
  120.         kStaticTextItemID
  121. };
  122.  
  123.  
  124.  
  125. enum
  126. {
  127.     // Strings
  128.  
  129.     kErrorStrings = 1000,
  130.     kMiscStrings
  131. };
  132.  
  133.  
  134.  
  135. enum
  136. {
  137.     // Error String Index
  138.     
  139.     kNeedSystem7 = 1,
  140.     kGenericErrorStr
  141. };
  142.  
  143.  
  144.  
  145. enum
  146. {
  147.     // Misc String Index
  148.     
  149.     kProgressStr = 1
  150.     
  151. };
  152.  
  153.  
  154.  
  155. enum
  156. {
  157.     // Internal flags
  158.  
  159.     kBarberPoleFinished = -1
  160. };
  161.  
  162.  
  163.  
  164. enum
  165. {
  166.     // Thread readability
  167.     
  168.     kDefaultStackSpace = 0,
  169.     kNoCreationOptions = 0
  170. };
  171.  
  172.  
  173.  
  174. // Non-Threaded typedefs
  175.  
  176. // Routine pointer to the operation being carried out. It
  177. // must call the UpdateOperation routine periodically.
  178. typedef Boolean (*tOperation) ( void* refCon, DialogRef theDialog );
  179.  
  180.  
  181.  
  182.  
  183. // Threaded typedefs
  184.  
  185. struct ThreadedOperationRec
  186. {
  187.     int            usageCount;
  188.     void*        refCon;
  189.     Boolean        bCancelled;
  190.     Boolean        bBarberPole;
  191.     int            maxAmount;
  192.     int            doneAmount;
  193.     int            drawnAmount;
  194.     Str255        theText;
  195. };
  196.  
  197. typedef struct ThreadedOperationRec tThreadedOperationRec, *tThreadedOperationPtr;
  198.  
  199.  
  200. // Routine pointer to the operation being carried out. It doesn't have to do
  201. // anything special except yield to other threads.
  202. typedef pascal SInt32 (*tThreadedOperation) ( tThreadedOperationPtr refCon );
  203.  
  204.  
  205.  
  206. // Global Variable Definitions. This allows me to include this file
  207. // in all sources with the extern keyword used in all instances except
  208. // the main source file.
  209.  
  210. #ifdef __MAIN__
  211.     #define    global
  212. #else
  213.     #define    global    extern
  214. #endif
  215.  
  216.  
  217.  
  218. global    Boolean                        gQuit;                  // quit program flag
  219. global    SInt32                        gSleepTime;
  220. global    Boolean                        gHasThreadManager;        // Do we have the Thread Manager?
  221.  
  222. global     UserItemUPP                    gOutlineUserItemUPP;
  223.  
  224.     
  225.  
  226.  
  227.  
  228. #endif    // __BAREBONES__
  229.